package io.renren.modules.generator.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.generator.entity.ContactsPeopleEntity;
import io.renren.modules.generator.service.ContactsPeopleService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author guijing
 * @email sunlightcs@gmail.com
 * @date 2022-01-31 16:10:18
 */
@RestController
@RequestMapping("generator/contactspeople")
public class ContactsPeopleController {
    @Autowired
    private ContactsPeopleService contactsPeopleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:contactspeople:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = contactsPeopleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{contactsId}")
    @RequiresPermissions("generator:contactspeople:info")
    public R info(@PathVariable("contactsId") Integer contactsId){
		ContactsPeopleEntity contactsPeople = contactsPeopleService.getById(contactsId);

        return R.ok().put("contactsPeople", contactsPeople);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:contactspeople:save")
    public R save(@RequestBody ContactsPeopleEntity contactsPeople){
		contactsPeopleService.save(contactsPeople);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:contactspeople:update")
    public R update(@RequestBody ContactsPeopleEntity contactsPeople){
		contactsPeopleService.updateById(contactsPeople);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:contactspeople:delete")
    public R delete(@RequestBody Integer[] contactsIds){
		contactsPeopleService.removeByIds(Arrays.asList(contactsIds));

        return R.ok();
    }

}
